<?php

// get the date
	$now =  current_time('mysql');
	$now_gmt = current_time('mysql',1);
	$now_text = date(' j F Y');
	$now_number = date('ymd');

	// give the topic dynamic titles	
	$new_posttitle = $wp_posttitle . $now_text;
	$new_postname = $wp_postname . $now_number;

	$wp_posttitle = $new_posttitle;
	$wp_postname = $new_postname;

	// build sql query
	$query  = "INSERT INTO $tableposts "
        . "(`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_status`, `comment_status`, `ping_status`, `post_name`, `post_modified`, `post_modified_gmt`) "
        . "VALUES "
        . "(" . $wp_userid . ", '" . $now . "', '" . $now_gmt . "', '" . addslashes($blog) . "', '" . addslashes($wp_posttitle) . "', 'publish', '" . $wp_allowcomments . "', '" . $wp_allowpings . "', '" . $wp_postname . "', '" . $now . "', '" . $now_gmt . "');";

	// run query
	$wpdb->query($query);

	// get categoryID
	$post_ID = $wpdb->get_var("SELECT ID FROM $tableposts ORDER BY ID DESC LIMIT 1");

	// Build category query
	$query = "INSERT INTO $tablepost2cat "
       . "(`post_id`, `category_id`) "
       . "VALUES "
       . "('" . $post_ID . "', '" . $wp_catid . "');";

	// Run Category Query
	$wpdb->query($query);
?>
